﻿@model Tasker.WebUI.Models.Tasks.TaskListShowModel

@{
    ViewBag.Title = "Задачи";
}

@section Sidebar
{
    <table class="filter">
						<tr class="item zero">
							<td class="l">
								<div>
									
										Мои задачи
									
								</div>
							</td>
							<td class="r">
								
							</td>
						</tr>
						<tr class="item zero deep1">
							<td class="l l1">
								<div>
									<a href="@Url.Action("Incoming", "Home")">
										Входящее
									</a>
								</div>
							</td>
							<td class="r">
								
							</td>
						</tr>
						<tr class="item zero deep1">
							<td class="l l1">
								<div>
									<a href="@Url.Action("Outcoming", "Home")">
										Исходящие
									</a>
								</div>
							</td>
							<td class="r">
								
							</td>
						</tr>
					</table>
}

<script type="text/javascript">

    $(document).ready(function () {
        $('#add-subtask').css("display", "none");
        $('.task-table tr').click(function () {
            if ($(this).hasClass('selected')) {
                $(this).removeClass('selected');
                $('#add-subtask').css("display", "none");
                $('#add-task').css("display", "block");
            } else {
                $('.task-table tr').removeClass('selected');
                $(this).addClass('selected');
                $('#add-subtask').css("display", "block");
                $('#parentTaskId').val($(this).attr('tid'));
                $('#add-task').css("display", "none");
            }
        });
    });

</script>

<div>
    <a href="@Url.Action("Create", "Task")" id="add-task"  class="btn btn-primary" style="float: right;">
        Поставить задачу
    </a>
    @using (Html.BeginForm("CreateSubTask", "Task", FormMethod.Post))
    {
        <input type="hidden" id="parentTaskId" name="parentTaskId" value=""/>
        <a href="javascript:;" id="add-subtask" onclick="$(this).parents('form').submit();"  class="btn btn-primary" style="float: right;">
            Поставить подзадачу
        </a>
    }
</div>

<h2>Задачи</h2>

<table class="items-table task-table folder-incoming ui-floating-table">
    <thead>
        <tr class="tr-setting-columns">
            <th class="c-sub first-element">
                <div class="head-icon">
                
                </div>
            </th>
            <th class="c-sndtbl-name">
                <div class="inner">
                    <div sortparam="sortby">
                        <a href="#">
                            Задача
                        </a>
                    </div>
                </div>
            </th>
            <th class="c-sndtbl-deadline">
                <div class="inner">
                    <div sortparam="sortby">
                        <a href="#">
                            Начало
                        </a>													
                    </div>
                </div>
            </th>
            <th class="c-sndtbl-deadline">
                <div class="inner">
                    <div sortparam="sortby">
                        <a href="#">
                            Конец
                        </a>													
                    </div>
                </div>
            </th>
            <th class="c-sndtbl-responsible">
                <div class="inner">
                    <div sortparam="sortby">
                        <a href="#">
                            Исполнители
                        </a>													
                    </div>
                </div>
            </th>
            <th class="c-sndtbl-owner">
                <div class="inner">
                    <div sortparam="sortby">
                        <a href="#">
                            Постановщик
                        </a>													
                    </div>
                </div>
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var task in Model.Tasks)
        {
            <tr id="e1000007" class="item s22" tid="@task.Id">
                <td class="c-sub selectable">
				    <div class="c-ico">
						<div class="ico subTasksDiv" onclick="bumsSubTasksToggle(event)">
						</div>
					</div>
			    </td>
                <td class="c-nm selectable">
                    <div class="c-nm">
                        <a href="@Url.Action("Index", "Task", new {id=task.Id})">
                            @task.Name
                        </a>
                        <div class="tags" id="tags1000087">
                            <span class="tag-list">
                            </span>
                        </div>
                    </div>
                </td>
                <td class="c-dl selectable">
                    @task.StartDate						
                </td>
                <td class="c-dl selectable">
                    @task.FinishDate						
                </td>
                <td class="c-res selectable">
                    <a href="@Url.Action("ShowProfile", "Staff", new {id=task.TaskWorkerId})">
                        @task.TaskWorkerFullName
                    </a>
                </td>
                <td class="c-own selectable">
                    <a href="@Url.Action("ShowProfile", "Staff", new {id=task.AuthorId})">
                        @task.AuthorFullName
                    </a>
                </td>
            </tr>
            
        }
    </tbody>
</table>